#include "MyQtHttpRespEventHandler.h"
#include "Constants.h"

MyQtHttpRespEventHandler::MyQtHttpRespEventHandler(){};

MyQtHttpRespEventHandler::~MyQtHttpRespEventHandler(){};

void MyQtHttpRespEventHandler::handleOriginRespSucceedEvent(QNetworkReply *reply){
    int eventId=parseEventId(reply->url());
    handleRespSucceedEvent(reply,eventId);
};

void MyQtHttpRespEventHandler::handleOriginRespErrorEvent(QNetworkReply::NetworkError error){
    int eventId=0;
    handleRespErrorEvent(error,eventId);
};

int MyQtHttpRespEventHandler::parseEventId(const QUrl &url){
    if(url.hasQueryItem(QString(EVENT_ID_KEY))){
        QString idStr= url.queryItemValue(QString(EVENT_ID_KEY));
        return idStr.toInt();
    }

    return 0;
}

void MyQtHttpRespEventHandler::handleNetworkErrorEvent(){
}
